home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / RCS_56.ARJ / RCSTEST < prev    next >
Text File  |  1992-02-11  |  10KB  |  398 lines

  1. #!/bin/sh
  2.  
  3. # Test RCS's functions.
  4. # The RCS commands are searched for in the PATH as usual;
  5. # to test the working directory's commands, prepend . to your PATH.
  6.  
  7. # Test RCS by creating files RCS/a.* and RCS/a.c.
  8. # If all goes well, output nothing, and remove the temporary files.
  9. # Otherwise, send a message to standard output.
  10. # Exit status is 0 if OK, 1 if an RCS bug is found, and 2 if scaffolding fails.
  11. # With the -v option, output more debugging info.
  12.  
  13. # If diff outputs `No differences encountered' when comparing identical files,
  14. # then rcstest may also output these noise lines; ignore them.
  15.  
  16. # The current directory and ./RCS must be readable, writable, and searchable.
  17.  
  18. #    $Id: rcstest,v 5.8 1991/11/20 17:58:10 eggert Exp $
  19.  
  20.  
  21. #    Copyright 1990, 1991 by Paul Eggert
  22. #    Distributed under license by the Free Software Foundation, Inc.
  23. #
  24. # This file is part of RCS.
  25. #
  26. # RCS is free software; you can redistribute it and/or modify
  27. # it under the terms of the GNU General Public License as published by
  28. # the Free Software Foundation; either version 2, or (at your option)
  29. # any later version.
  30. #
  31. # RCS is distributed in the hope that it will be useful,
  32. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  34. # GNU General Public License for more details.
  35. #
  36. # You should have received a copy of the GNU General Public License
  37. # along with RCS; see the file COPYING.  If not, write to
  38. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  39. #
  40. # Report problems and direct all questions to:
  41. #
  42. #     rcs-bugs@cs.purdue.edu
  43.  
  44. RCSINIT=-x
  45. export RCSINIT
  46.  
  47. SLASH=/
  48. RCSfile=RCS${SLASH}a.c
  49. RCS_alt=RCS${SLASH}a.d
  50. lockfile=RCS${SLASH}a._
  51.  
  52. case $1 in
  53. -v) q=; set -x;;
  54. '') q=-q;;
  55. *) echo >&2 "$0: usage: $0 [-v]"; exit 2
  56. esac
  57.  
  58. test -d RCS || {
  59.     echo >&2 "$0: RCS: not a directory; please \`mkdir RCS' first."
  60.     exit 1
  61. }
  62.  
  63. rm -f a.* $RCSfile $RCS_alt $lockfile &&
  64. echo 1.1 >a.11 &&
  65. echo 1.1.1.1 >a.3x1 &&
  66. echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; }
  67.  
  68. case `diff -c a.11 a.3x1` in
  69. *'! 1.1.1.1')
  70.     diff='diff -c';;
  71. *)
  72.     echo "#warning: diff -c does not work, so diagnostics may be cryptic"
  73.     diff=diff
  74. esac
  75.  
  76. rcs -i -L -ta.11 $q a.c &&
  77. <$RCSfile || {
  78.     echo "#rcs -i -L failed; perhaps RCS is not properly installed."
  79.     exit 1
  80. }
  81.  
  82. rlog a.c >/dev/null || { echo "#rlog failed on empty RCS file"; exit 1; }
  83. rm -f $RCSfile || exit 2
  84.  
  85. cp a.11 a.c &&
  86. ci -ta.11 -mm $q a.c &&
  87. <$RCSfile &&
  88. rcs -L $q a.c || { echo "#ci+rcs -L failed"; exit 1; }
  89. test ! -f a.c || { echo "#ci did not remove working file"; exit 1; }
  90. for l in '' '-l'
  91. do
  92.     co $l $q a.c &&
  93.     test -f a.c || { echo '#co' $l did not create working file; exit 1; }
  94.     $diff a.11 a.c || { echo '#ci' followed by co $l is not a no-op; exit 1; }
  95. done
  96.  
  97. cp a.12 a.c &&
  98. ci -mm $q a.c &&
  99. co $q a.c &&
  100. $diff a.12 a.c || { echo "#ci+co failed"; exit 1; }
  101.  
  102. co -r1.1 $q a.c &&
  103. $diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; }
  104.  
  105. rm -f a.c &&
  106. cp a.3x1 a.c &&
  107. ci -r1.1.1 -mm $q a.c &&
  108. co -r1.1.1.1 $q a.c &&
  109. $diff a.3x1 a.c || { echo "#branches failed"; exit 1; }
  110.  
  111. co -l $q a.c &&
  112. ci -f -mm $q a.c &&
  113. co -r1.3 $q a.c &&
  114. $diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; }
  115.  
  116. co -l $q a.c &&
  117. echo 1.4 >a.c &&
  118. ci -l -mm $q a.c &&
  119. echo error >a.c &&
  120. ci -mm $q a.c || { echo "#ci -l failed"; exit 1; }
  121.  
  122. co -l $q a.c &&
  123. echo 1.5 >a.c &&
  124. ci -u -mm $q a.c &&
  125. <a.c || { echo "#ci -u didn't create a working file"; exit 1; }
  126. rm -f a.c &&
  127. echo error >a.c || exit 2
  128. ci -mm $q a.c 2>/dev/null && { echo "#ci -u didn't unlock the file"; exit 1; }
  129.  
  130. rm -f a.c &&
  131. rcs -l $q a.c &&
  132. co -u $q a.c || { echo "#rcs -l + co -u failed"; exit 1; }
  133. rm -f a.c &&
  134. echo error >a.c || exit 2
  135. ci -mm $q a.c 2>/dev/null && { echo "#co -u didn't unlock the file"; exit 1; }
  136.  
  137. rm -f a.c &&
  138. cp a.11 a.c &&
  139. co -f $q a.c || { echo "#co -f failed"; exit 1; }
  140. $diff a.11 a.c >/dev/null && { echo "#co -f had no effect"; exit 1; }
  141.  
  142. co -p1.1 $q a.c >a.t &&
  143. $diff a.11 a.t || { echo "#co -p failed"; exit 1; }
  144.  
  145. for n in n N
  146. do
  147.     rm -f a.c &&
  148.     co -l $q a.c &&
  149.     echo $n >a.$n &&
  150.     cp a.$n a.c &&
  151.     ci -${n}n -mm $q a.c &&
  152.     co -rn $q a.c &&
  153.     $diff a.$n a.c || { echo "#ci -$n failed"; exit 1; }
  154. done
  155.  
  156. case $LOGNAME in
  157. ?*) me=$LOGNAME;;
  158. *)
  159.     case $USER in
  160.     ?*) me=$USER;;
  161.     *)
  162.         me=`who am i` || exit 2
  163.         me=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
  164.         case $me in
  165.         '') echo >&2 "$0: cannot deduce user name"; exit 2
  166.         esac
  167.     esac
  168. esac
  169. date=`date -u 2>/dev/null` ||
  170. date=`TZ=GMT0 date 2>/dev/null` ||
  171. date=`TZ= date` || exit 2
  172. set $date
  173. case $2 in
  174. Jan) m=01;; Feb) m=02;; Mar) m=03;; Apr) m=04;; May) m=05;; Jun) m=06;;
  175. Jul) m=07;; Aug) m=08;; Sep) m=09;; Oct) m=10;; Nov) m=11;; Dec) m=12;;
  176. *) echo >&2 "$0: $2: unknown month name"; exit 2
  177. esac
  178. case $3 in
  179. ?) d=0$3;;
  180. *) d=$3
  181. esac
  182. case $6 in
  183. [0-9][0-9][0-9][0-9]*) D=$6/$m/$d;;
  184. *)
  185.     case $5 in
  186.     [0-9][0-9][0-9][0-9]*) D=$5/$m/$d;;
  187.     *) echo >&2 "$0: bad date format: $date"; exit 2
  188.     esac
  189. esac
  190. T=$4
  191. case $PWD in
  192. '') PWD=`pwd`
  193. esac &&
  194. co -l $q a.c &&
  195. sed 's/@/$/g' >a.kv <<EOF
  196. @Author: w @
  197. @Date: $D $T @
  198. @Header: $PWD$SLASH$RCSfile 2.1 $D $T w s @
  199. @Id: a.c 2.1 $D $T w s @
  200. @Locker:  @
  201. @Log: a.c @
  202.  * Revision 2.1  $D  $T  w
  203.  * m
  204.  *
  205. @RCSfile: a.c @
  206. @Revision: 2.1 @
  207. @Source: $PWD$SLASH$RCSfile @
  208. @State: s @
  209. EOF
  210. test $? = 0 &&
  211. sed 's/:.*\$/$/' a.kv >a.k &&
  212. sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl &&
  213. sed -e '/^\$/!d' -e 's/\$$/: old $/' a.k >a.o &&
  214. sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v &&
  215. cp a.o a.c &&
  216. ci -d"$date" -ss -ww -u2.1 -mm $q a.c &&
  217. $diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; }
  218. co -p -ko $q a.c >a.oo &&
  219. $diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; }
  220. cp a.kv a.o || exit 2
  221. rcs -o2.1 $q a.c &&
  222. rcs -l $q a.c &&
  223. ci -k -u $q a.c &&
  224. $diff a.kv a.c || { echo "#ci -k failed"; exit 1; }
  225. sed '/^[^$]/d' a.kv >a.i &&
  226. ident a.c >a.i1 &&
  227. sed -e 1d -e 's/^[     ]*//' a.i1 >a.i2 &&
  228. $diff a.i a.i2 || { echo "#ident failed"; exit 1; }
  229.  
  230. rcs -i $q a.c 2>/dev/null && { echo "#rcs -i permitted existing file"; exit 1; }
  231.  
  232. co -l $q a.c &&
  233. echo 2.2 >a.c &&
  234. ci -mm $q a.c &&
  235. echo 1.1.1.2 >a.c &&
  236. rcs -l1.1.1 $q a.c &&
  237. ci -r1.1.1.2 -mm $q a.c &&
  238. rcs -b1.1.1 $q a.c &&
  239. test " `co -p $q a.c`" = ' 1.1.1.2' || { echo "#rcs -b1.1.1 failed"; exit 1; }
  240. rcs -b $q a.c &&
  241. test " `co -p $q a.c`" = ' 2.2' || { echo "#rcs -b failed"; exit 1; }
  242.  
  243. echo 2.3 >a.c || exit 2
  244. rcs -U $q a.c || { echo "#rcs -U failed"; exit 1; }
  245. ci -mm $q a.c || { echo "#rcs -U didn't unset strict locking"; exit 1; }
  246. rcs -L $q a.c || { echo "#rcs -L failed"; exit 1; }
  247. echo error >a.c || exit 2
  248. ci -mm $q a.c 2>/dev/null && { echo "#ci retest failed"; exit 1; }
  249.  
  250. rm -f a.c &&
  251. log0=`rlog -h a.c` &&
  252. co -l $q a.c &&
  253. ci -mm $q a.c &&
  254. log1=`rlog -h a.c` &&
  255. test " $log0" = " $log1" || { echo "#unchanged ci didn't revert"; exit 1; }
  256.  
  257. rm -f a.c &&
  258. rcs -nN:1.1 $q a.c &&
  259. co -rN $q a.c &&
  260. $diff a.11 a.c || { echo "#rcs -n failed"; exit 1; }
  261.  
  262. rcs -NN:2.1 $q a.c &&
  263. co -rN $q a.c &&
  264. $diff a.kv a.c || { echo "#rcs -N failed"; exit 1; }
  265.  
  266. co -l $q a.c &&
  267. rcs -c':::' $q a.c &&
  268. echo '$''Log$' >a.c &&
  269. ci -u -mm $q a.c &&
  270. test " `sed '$!d' a.c`" = ' :::' || { echo "#rcs -c failed"; exit 1; }
  271.  
  272. rcs -o2.2: $q a.c &&
  273. co $q a.c &&
  274. $diff a.kv a.c || { echo "#rcs -o failed"; exit 1; }
  275.  
  276. rcsdiff -r1.1 -r2.1 $q a.c >a.0
  277. case $? in
  278. 1) ;;
  279. *) echo "#rcsdiff bad status"; exit 1
  280. esac
  281. diff a.11 a.kv >a.1
  282. $diff a.0 a.1 || { echo "#rcsdiff failed"; exit 1; }
  283.  
  284. rcs -l2.1 $q a.c || { echo "#rcs -l2.1 failed"; exit 1; }
  285. for i in k kv kvl o v
  286. do
  287.     rm -f a.c &&
  288.     cp a.$i a.c &&
  289.     rcsdiff -k$i $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; }
  290. done
  291. co -p1.1 -ko $q a.c >a.t &&
  292. $diff a.11 a.t || { echo "#co -p1.1 -ko failed"; exit 1; }
  293. rcs -u2.1 $q a.c || { echo "#rcs -u2.1 failed"; exit 1; }
  294.  
  295. rm -f a.c &&
  296. co -l $q a.c &&
  297. cat >a.c <<'EOF'
  298. 2.2
  299. a
  300. b
  301. c
  302. d
  303. EOF
  304. test $? = 0 &&
  305. ci -l -mm $q a.c &&
  306. co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
  307. ci -l -mm $q a.c &&
  308. co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
  309. cat >a.0 <<'EOF'
  310. 2.3
  311. a
  312. b1
  313. c
  314. d1
  315. EOF
  316. cat >a.1 <<'EOF'
  317. <<<<<<< a.c
  318. new
  319. =======
  320. 2.3
  321. >>>>>>> 2.3
  322. a
  323. b1
  324. c
  325. d1
  326. EOF
  327. rcsmerge -r2.2 -r2.3 $q a.c
  328. case $? in
  329. 0)
  330.     if $diff a.0 a.c >/dev/null
  331.     then echo "#warning: diff3 -E does not work, " \
  332.         "so merge and rcsmerge ignore overlaps and suppress overlap lines."
  333.     else
  334.         $diff a.1 a.c || { echo "#rcsmerge failed (status 0)"; exit 1; }
  335.         echo "#warning: The diff3 lib program exit status ignores overlaps," \
  336.             "so rcsmerge does not warn about overlap lines that it generates."
  337.     fi
  338.     ;;
  339. 1)
  340.     $diff a.1 a.c || { echo "#rcsmerge failed (status 1)"; exit 1; }
  341.     ;;
  342. *)
  343.     echo "#rcsmerge bad status"; exit 1
  344. esac
  345.  
  346. nl='
  347. '
  348. {
  349.     co -p $q a.c | tr "$nl" '\200' >a.24 &&
  350.     cp a.24 a.c &&
  351.     ciOut=`(ci -l -mm $q a.c 2>&1)` &&
  352.     case $ciOut in
  353.     ?*) echo >&2 "$ciOut"
  354.     esac &&
  355.     co -p $q a.c | tr '\200' "$nl" >a.c &&
  356.     rcsdiff -r2.3 $q a.c >/dev/null &&
  357.  
  358.     echo 2.5 >a.c &&
  359.     ci -l -mm $q a.c &&
  360.     cp a.24 a.c &&
  361.     rcsdiff -r2.4 $q a.c >/dev/null
  362. } || echo "#warning: Traditional diff is used, so RCS is limited to text files."
  363.  
  364. rcs -u -o2.4: $q a.c || { echo "#rcs -u -o failed"; exit 1; }
  365.  
  366. rcs -i -Aa.c -t- $q a.d || { echo "#rcs -i -A failed"; exit 1; }
  367.  
  368. rlog -r2.1 a.c >a.t &&
  369. grep '^checked in with -k' a.t >/dev/null &&
  370. sed '/^checked in with -k/d' a.t >a.u &&
  371. $diff - a.u <<EOF
  372.  
  373. RCS file: $RCSfile
  374. Working file: a.c
  375. head: 2.3
  376. branch:
  377. locks: strict
  378. access list:
  379. symbolic names:
  380.     N: 2.1
  381.     n: 1.8
  382. comment leader: ":::"
  383. keyword substitution: kv
  384. total revisions: 13;    selected revisions: 1
  385. description:
  386. 1.1
  387. ----------------------------
  388. revision 2.1
  389. date: $D $T;  author: w;  state: s;  lines: +13 -1
  390. =============================================================================
  391. EOF
  392. test $? = 0 || { echo "#rlog failed"; exit 1; }
  393.  
  394.  
  395. test ! -f $lockfile || { echo "#lock file not removed"; exit 1; }
  396.  
  397. exec rm -f a.* $RCSfile $RCS_alt
  398.